import { AxiosResponse } from 'axios';
import {SongList, PersonalizeDj,
     Personalized, SongListView, SongMv} from '../../api/index';

// import {ListenMusic} from '../../Hook/index';

const songList: [] = []
const personalizeDj: [] = [];
const personalized: [] = [];
const songListView: [] = [];
const songMv: [] = [];

// const listenMusic: any = [];

export default {
    namespaced: true,

    actions: {
        // 推荐歌单
        async songList({commit}: any){
            console.log('推荐歌单');
            const {data}: any = await SongList()
            if(data.code === 200){
                commit('SONGLIST', data.result)
            }
        },

        async personalizeDj({commit}: any){
            console.log('推荐电台')
            const {data}: any = await PersonalizeDj()
            if(data.code === 200){
                commit('PERSIONALIZEDJ', data.data)
            }
        },

        async personalized({commit}: any){
            console.log('独家专享')
            const {data}: any = await Personalized()
            if(data.code === 200){
                commit('PERSONALIZED', data.result)
            }
        },

        async songListView({commit}: any){
            console.log('热门歌曲')
            const {data}: any = await SongListView()
            if(data.code === 200){
                commit('SONGLISTVIEW', data.data)
            }
        },

        async songMv({commit}: any){
            console.log('热门mv榜单')
            const {data}: any = await SongMv();
            console.log({data});
            if(data.code === 200){
                commit('SONGMV', data.result)
            }
        }

    },
    mutations: {
       
        //推荐歌单
        SONGLIST(state: any, data: []){
            state.songList = data
        },

        // 独家专享
        PERSIONALIZEDJ(state: any, data: []){
            state.personalizeDj = data
        },

        //热门歌单
        PERSONALIZED(state: any, data: []){
            state.personalized = data
        },

        //热门歌曲
        SONGLISTVIEW(state: any, data: []){
            state.songListView = data

        },
        SONGMV(state: any, data: []){
            state.songMv = data
        }

        // 获取音乐url
        // LISTENMUSIC(state: any, data: String | []){
        //     state.listenMusic = data
        // }

    },
    getters: {

    },

    // 模块内容（module assets）
    state: () => ({
        // 侧边栏
        songList,
        personalizeDj,
        personalized,
        songListView,
        songMv
        // listenMusic
    }), // 模块内的状态已经是嵌套的了，使用 `namespaced` 属性不会对其产生影响

}